package com.analysis.service;

import com.analysis.model.AnalysisResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Slf4j
@Service
public class CacheService {
    
    private final Map<String, AnalysisResult> cache = new ConcurrentHashMap<>();
    
    public AnalysisResult getResult(String key) {
        AnalysisResult result = cache.get(key);
        if (result != null) {
            log.info("缓存命中：{}", key);
        }
        return result;
    }
    
    public void cacheResult(String key, AnalysisResult result) {
        cache.put(key, result);
        log.info("结果已缓存：{}", key);
    }
}
